~ chicken-core (master) /manual/Module (chicken bytevector)
Trap1[[tags: manual]]
2[[toc:]]
3
4== Module (chicken bytevector)
5
6This module contains procedures for dealing with "bytevectors". Blobs are
7unstructured byte arrays (basically "binary strings"). You can't do
8much with them, but they allow conversion to and from
9[[Module srfi-4|SRFI-4 number vectors]] which define how to access a
10bytevector's byte contents.
11
12=== bytevector
13
14<procedure>(bytevector FIXNUM ...)</procedure>
15
16Returns a new bytevector containing the values {{FIXNUM ...}}.
17
18=== make-bytevector
19
20<procedure>(make-bytevector SIZE)</procedure>
21
22Returns a bytevector object of {{SIZE}} bytes, aligned on an 8-byte boundary,
23uninitialized.
24
25=== bytevector?
26
27<procedure>(bytevector? X)</procedure>
28
29Returns {{#t}} if {{X}} is a bytevector object, or
30{{#f}} otherwise.
31
32=== bytevector-length
33
34<procedure>(bytevector-length BYTEVECTOR)</procedure>
35
36Returns the number of bytes in {{BYTEVECTOR}}.
37
38=== bytevector-u8-ref
39
40<procedure>(bytevector-u8-ref BYTEVECTOR INDEX)</procedure>
41
42Returns the byte at {{INDEX}} in {{BYTEVECTOR}}.
43
44=== bytevector-u8-set!
45
46<procedure>(bytevector-u8-set! BYTEVECTOR INDEX VALUE)</procedure>
47
48Destructively modifies the byte at {{INDEX}} in {{BYTEVECTOR}} to {{VALUE}}, which
49should be a fixnum.
50
51=== utf8->string
52
53<procedure>(utf8->string BYTEVECTOR [VALIDATE])</procedure>
54
55Returns a string with the contents of {{BYTEVECTOR}}. if {{VALIDATE}}
56is given and false, then invalidly
57encoded characters do not signal an error - byte-sequences that do no represent
58valid UTF-8 characters are retained and, if extracted with {{string-ref}}
59are converted to a trailing surrogate pair half in the range U+DC80 to U+DCFF.
60
61=== string->utf8
62
63<procedure>(string->utf8 STRING)</procedure>
64
65Returns a bytevector with the contents of {{STRING}}.
66
67=== latin1->string
68
69<procedure>(latin1->string BYTEVECTOR)</procedure>
70
71Returns a string with the contents of {{BYTEVECTOR}} converted from Latin-1 (ISO-8859-1) encoding to UTF-8.
72
73=== string->latin1
74
75<procedure>(string->latin1 STRING)</procedure>
76
77Returns a bytevector with the contents of {{STRING}} encoded as Latin-1 (ISO-?8859-1).
78
79=== bytevector=?
80
81<procedure>(bytevector=? BYTEVECTOR1 BYTEVECTOR2)</procedure>
82
83Returns {{#t}} if the two argument bytevectors are of the same
84size and have the same content.
85
86=== bytevector-append
87
88<procedure>(bytevector-append BYTEVECTOR ...)</procedure>
89
90Returns a new bytevector holding the concatenated contents of all
91argument bytevectors.
92
93=== bytevector-copy
94
95<procedure>(bytevector-copy BYTEVECTOR #!optional START END)</procedure>
96
97Returns a new bytevector holding the contents of {{BYTEVECTOR}} between
98the indices {{START}} to {{END}}.
99
100=== bytevector-copy!
101
102<procedure>(bytevector-copy! TO AT FROM #!optional START END)</procedure>
103
104Copioes the contents of the bytevector FROM between
105the indices {{START}} to {{END}} into the bytevector {{TO}}, starting at
106index {{AT}}.
107
108
109---
110Previous: [[Module (chicken bitwise)]]
111
112Next: [[Module (chicken condition)]]
113
114